package com.syni.mdd.yhd.common.all.dao.jpa;

import com.syni.mdd.yhd.common.all.dao.BaseJPADao;
import com.syni.mdd.yhd.common.all.entity.BmsBusiness;
import com.syni.mdd.yhd.common.all.entity.BmsBusinessTypeRelation;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Map;
import java.util.Set;

public interface BmsBusinessTypeRelationDao extends BaseJPADao<BmsBusinessTypeRelation,Integer> {
    List<BmsBusinessTypeRelation> findByBmsBusinessId(Integer businessId);

    BmsBusinessTypeRelation findByBmsBusinessIdAndBmsTypeId(Integer businessId,Integer typeId);

    @Query(value = "select bb.id from bms_business bb left join bms_business_type_relation bbt on bb.id = bbt.bms_business_id" +
            " where bb.is_auth = 1 and bbt.bms_type_id = ?1",nativeQuery = true)
    List<Map<String, Object>> findAuthBusinessIdInType(Integer typeId);

    List<BmsBusinessTypeRelation> findByBmsBusinessIdIn(Set<Integer> businessIds);
}
